package com.hyphenate.chatuidemo.utils;

import com.hyphenate.chat.EMConversation;
import com.hyphenate.chat.EMMessage;
import com.hyphenate.chat.EMTextMessageBody;

/**
 * Created by bianxiang on 16/4/25.
 */
public class SendMsgUtils {
    /**
     * 自动发送消息
     *
     * @param from     发送者
     * @param to       接收者
     * @param sendText 发送文本
     */
    public static void autoSendMessage( EMConversation conversation ,String from, String to, String sendText) {


//        EMConversation conversation = EMClient.getInstance().chatManager().getConversation(from);

        EMMessage message = EMMessage.createReceiveMessage(EMMessage.Type.TXT);
        message.setFrom(from);
        message.setTo(to);
        message.addBody(new EMTextMessageBody(sendText));
        message.setChatType(EMMessage.ChatType.Chat);
        message.setTo(to);
        message.setMsgTime(System.currentTimeMillis());
//        EMClient.getInstance().chatManager().saveMessage(message);
//        EMClient.getInstance().chatManager().updateMessage(message);


//        EMMessage message = EMMessage.createReceiveMessage(EMMessage.Type.TXT);
//        message.setFrom("admin");
//        message.setReceipt("test1");
//        message.addBody(new EMTextMessageBody("hshhshshhsshhshss"));
//        message.setChatType(EMMessage.ChatType.Chat);
//        message.setTo("test1");
        message.setMsgTime(System.currentTimeMillis());
        conversation.insertMessage(message);

    }
}
